class HttpError extends Error {
  constructor(status, message, code = 'http_error', details) {
    super(message);
    this.status = status;
    this.code = code;
    if (details) {
      this.details = details;
    }
  }
}

function createValidationError(details) {
  return new HttpError(400, 'Validation failed', 'validation_error', details);
}

module.exports = {
  HttpError,
  createValidationError
};
